package com.twu.biblioteca;

import java.util.ArrayList;

/**
 * Created by mgehwolf on 04/08/2014.
 */
public class UserList {
    private static ArrayList<User> userList;

    public UserList(){
        userList  = new ArrayList<User>();
        userList.add(new User("Martina", "mgehwolf@thoughtworks.com", "1q2w3e4r", "111-2222","mgehwolf@thoughtworks.com", "08733388"));
        userList.add(new User("name", "somebody", "notimportant", "222-1111", "nobody@thoughtworks.com", "08700088"));
    }

    public static User validateUser(String[] libraryNumerPassword) {
        for(int i=0; i<userList.size(); i++){
            if (userList.get(i).getLibraryNumber().equals(libraryNumerPassword[0]) && userList.get(i).getPassword().equals(libraryNumerPassword[1])) {
                System.out.println("Welcome " + userList.get(i).getName());
                return userList.get(i);
            }
        }
        System.out.println("Unsuccessful Login");
        return new User ();
    }
    public void viewUserList(){
        for (int i = 0; i < userList.size(); i++) {
            System.out.println(i + ") " + userList.get(i).getLibraryNumber() + " " + userList.get(i).getUsername());
        }
    }
    public LibraryItemList viewUserList(int i){
        return userList.get(i).getLibraryItemList();
    }
}
